package com.yizhu.zczy.user.controller;

import java.util.Arrays;
import java.util.Map;


import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yizhu.zczy.user.entity.FortuneEntity;
import com.yizhu.zczy.user.service.FortuneService;




/**
 * 财富中心
 *
 * @author guoyz
 * @email guoyz@mail.com
 * @date 2021-06-24 18:36:29
 */
@RestController
@RequestMapping("user/fortune")
public class FortuneController {
    @Autowired
    private FortuneService fortuneService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("user:fortune:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = fortuneService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{fortuneId}")
    //@RequiresPermissions("user:fortune:info")
    public R info(@PathVariable("fortuneId") Integer fortuneId){
		FortuneEntity fortune = fortuneService.getById(fortuneId);

        return R.ok().put("fortune", fortune);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("user:fortune:save")
    public R save(@RequestBody FortuneEntity fortune){
		fortuneService.save(fortune);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("user:fortune:update")
    public R update(@RequestBody FortuneEntity fortune){
		fortuneService.updateById(fortune);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("user:fortune:delete")
    public R delete(@RequestBody Integer[] fortuneIds){
		fortuneService.removeByIds(Arrays.asList(fortuneIds));

        return R.ok();
    }

}
